<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>
        // 检测构造函数的原型链
        function A() { }
        function B() { }
        function C() { }
        let c = new C();
        // 将B的原型修改为c
        B.prototype = c;
        let b = new B();
        // 将A的原型改为b
        A.prototype = b;
        let a = new A();
        // 原型链 a => b => c
        console.log(b instanceof C); // true
        console.log(a instanceof B); // true
        console.log(a instanceof C); // true

        // 检测对象的原型链
        let obj1 = {};
        let obj2 = {};
        Object.setPrototypeOf(obj1,obj2); // 将obj1的原型设置为obj2
        // Object.prototype=obj1.__proto__
        console.log(obj1)
        // obj1是否在obj2的原型链上
        console.log(obj2.isPrototypeOf(obj1)); // true
        // obj1是否在Object的原型链上
        console.log(Object.prototype.isPrototypeOf(obj1)); // true
    </script>
</body>

</html>